home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
sys
/
koadd.lzh
/
link
/
link040.lzh
/
link.s
next >
Wrap
Text File
|
1995-06-20
|
12KB
|
736 lines
******
****** link.x シンボリックリンク by 小笠原博之
******
****** SPS-NET: SPS0783 COR. / oga@dgw.yz.yamagata-u.ac.jp
******
****** 1991 9/09: v0.01
****** :
****** 1991 12/2: v0.30
******
****** 1995 6/20: v0.40patch
******
.include doscall.mac
VERSION = '0.40'
***
*** マクロ定義
***
INSUPER macro
local _isuper
clr.l a1
move.w sr,d0
and.w #$2000,d0
bne _isuper
moveq.l #$81,d0
trap #15
move.l d0,a1 * ssp
_isuper:
endm
OUTSUPER macro
local _osuper
moveq.l #0,d0
cmp.l d0,a1
beq _osuper
moveq.l #$81,d0
trap #15
_osuper:
endm
***
.text
.even
***
*** 常駐ヘッダ
***
KeepStart:
.dc.b 'SYMBLINKver '
.dc.l VERSION
***
*** vector table
***
.dc.l dosvectortable
.dc.l functiontable
CHGVECTN = 12
dosvectortable:
oldvectMKDIR dc.l 0 *39
oldvectRMDIR dc.l 0 *3a
oldvectCHDIR dc.l 0 *3b
oldvectCREATE dc.l 0 *3c
oldvectOPEN dc.l 0 *3d
oldvectDELETE dc.l 0 *41
oldvectCHMOD dc.l 0 *43
oldvectFILES dc.l 0 *4e
oldvectRENAME dc.l 0 *56
oldvectMAKETMP dc.l 0 *5a
oldvectNEWFILE dc.l 0 *5b
oldvectASSIGN dc.l 0 *5f
functiontable:
.dc.l GetLinkPathEnt
.dc.l PathCompleteEnt
.dc.l LinkSwitchEnt
.dc.l LinkSetNorecEnt
***
*** リンクファイル名変換の外部呼び出しエントリ
***
GetLinkPathEnt:
move.l 8(sp),d2 * word buffer
move.l 4(sp),a2 * input path
INSUPER
exg a1,d2
bsr linkcheck2
move.l a2,(a1)
move.w 256+2(a1),d1
move.l d2,a1
OUTSUPER
move.l d1,d0
ext.l d0
rts
***
*** リンク進路名変換の外部呼び出しエントリ
***
PathCompleteEnt:
move.l a3,-(sp)
move.l 4+4(sp),a3 *path
INSUPER
move.l a1,-(sp)
bsr pathcomplete3
move.l (sp)+,a1
OUTSUPER
move.l (sp)+,a3
rts
***
*** 変換の一時 ON/OFF
***
LinkSwitchEnt:
move.w #_CHMOD,d0
tst.l 4(sp)
bne switchon
move.w #'p ',d0 *?
switchon:
move.w d0,linkswitch
****
****
****
moveq.l #0,d0
rts
***
*** 最大変換回数設定
***
LinkSetNorecEnt:
move.w 4+2(sp),norec
rts
***
*** DOS CALL のエントリ
***
* 39
KeepEntMKDIR:
move.l oldvectMKDIR(pc),a0
bra dos_exec_arg1
* 3a
KeepEntRMDIR:
move.l oldvectRMDIR(pc),a0
bra dos_exec_arg1
* 3c
KeepEntCREATE:
move.l oldvectCREATE(pc),a0
bra dos_exec_arg2w
* 3d
KeepEntOPEN:
move.l oldvectOPEN(pc),a0
bra dos_exec_arg2w
* 41
KeepEntDELETE:
move.l oldvectDELETE(pc),a0
dos_exec_nlc_arg1:
movem.l d1/a0-a3,-(sp)
addq.w #1,lastchange
bsr pathcomplete_static
clr.w lastchange
tst.w d0
bmi errorret
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.l d0,-(sp)
move.l sp,a6
jsr (a0)
addq.l #4,sp
rts
* 43
KeepEntCHMOD:
move.l oldvectCHMOD(pc),a0
bra dos_exec_arg2w
* 56
KeepEntRENAME:
move.l oldvectRENAME(pc),a0
dos_exec_nlc_arg2l:
movem.l d1/a0-a3,-(sp)
addq.w #1,lastchange
bsr pathcomplete_static
clr.w lastchange
tst.w d0
bmi errorret
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.l 4(a6),-(sp)
move.l d0,-(sp)
move.l sp,a6
jsr (a0)
addq.l #8,sp
rts
* 5a->8a
KeepEntMAKETMP:
move.l oldvectMAKETMP(pc),a0
jmp (a0)
* 5b->8b
KeepEntNEWFILE:
move.l oldvectNEWFILE(pc),a0
dos_exec_arg2w:
movem.l d1/a0-a3,-(sp)
bsr pathcomplete_static
tst.w d0
bmi errorret
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.w 4(a6),-(sp)
move.l d0,-(sp)
move.l sp,a6
jsr (a0)
addq.l #6,sp
rts
dos_exec_arg1:
movem.l d1/a0-a3,-(sp)
bsr pathcomplete_static
tst.w d0
bmi errorret
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.l d0,-(sp)
move.l sp,a6
jsr (a0)
addq.l #4,sp
rts
***
*** DOS _FILES のエントリ 4e
***
KeepEntFILES:
movem.l d1/a0-a3,-(sp)
move.l 4(a6),a0
addq.w #1,lastchange
bsr pathcomplete_static_a6_2
clr.w lastchange
tst.w d0
bmi errorret
move.l a2,d0 * 4(a6)
movem.l (sp)+,d1/a0-a3
move.l oldvectFILES(pc),a0
move.w 8(a6),-(sp)
move.l d0,-(sp)
move.l (a6),-(sp)
move.l sp,a6
jsr (a0)
lea.l 10(sp),sp
rts
***
*** DOS _CHDIR のエントリ 3b
***
KeepEntCHDIR:
movem.l d1/a0-a3,-(sp)
bsr pathcomplete_static
tst.w d0
bmi errorret
* move.l a2,(a6)
tst.w change
beq notchdrv
move.l a2,a0 * move.l (a6),a0
move.b (a0)+,d0
beq notchdrv
cmp.b #':',(a0)
bne notchdrv
subq.w #1,d0
and.w #$1f,d0
move.w d0,-(sp)
DOS _CHGDRV
addq.w #2,sp
notchdrv:
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.l oldvectCHDIR(pc),a0
move.l d0,-(sp)
move.l sp,a6
jsr (a0)
addq.l #4,sp
rts
errorret:
movem.l (sp)+,d1/a0-a3
rts
***
*** DOS _ASSIGN エントリ 5f
***
KeepEntASSIGN:
move.l oldvectASSIGN(pc),a0
movem.l d1/a0-a3,-(sp)
cmp.w #1,(a6)
bne jmpold
move.l 6(a6),a0
bsr pathcomplete_static_a6_2
tst.w d0
bmi errorret
move.l a2,d0
movem.l (sp)+,d1/a0-a3
move.w 10(a6),-(sp)
move.l d0,-(sp)
move.l 2(a6),-(sp)
move.w (a6),-(sp)
move.l sp,a6
jsr (sp)
lea.l 12(sp),sp
rts
jmpold:
movem.l (sp)+,d1/a0-a3
jmp (a0)
***
*** 進路名展開
***
pathcomplete_static:
move.l (a6),a0
pathcomplete_static_a6_2:
lea pathbuf(pc),a1
move.l a1,a3
pathcpyloop:
move.b (a0)+,(a1)+
bne pathcpyloop
pathcomplete3:
lea buffer(pc),a0
move.l a0,d1
pathcomplete:
move.l a3,a0
retrypathcomp:
move.l a0,a2 * a0:path
move.b (a2)+,d0
beq exitpathcomp * short cut
cmp.b #'\',d0
beq pathcompent
cmp.b #'/',d0
beq pathcompent
notcount:
move.l a2,a3
move.b (a3)+,d0
cmp.b #':',d0
bne notcount2
move.b (a3)+,d0
cmp.b #'\',d0
beq countup2
cmp.b #'/',d0
bne notcount2
countup2:
move.l a3,a2
notcount2:
subq.w #1,a2
pathcompent:
pathcomploop:
move.b (a2)+,d0
beq exitpathcomp
cmp.b #'\',d0
beq pathdir
cmp.b #'/',d0
bne pathnotdir
pathdir:
move.b -(a2),d2
clr.b (a2)
movem.l d1/a0/a2,-(sp)
move.l a0,a2 * input path
move.l d1,a1 * buffer
bsr linkcheck3
movem.l (sp)+,d1/a0/a2
tst.w d0
bmi errreturn
move.w 256+2(a1),d0
move.b d2,(a2)+
tst.w d0
beq pathcomploop *notchange
lea 8(a1),a3
loopfindstrnull:
tst.b (a3)+
bne loopfindstrnull
subq.w #1,a3
subq.w #1,a2
loopstrcatptr:
move.b (a2)+,(a3)+
bne loopstrcatptr
lea 8(a1),a3
move.l a0,a2
loopstrcpyptr:
move.b (a3)+,(a2)+
bne loopstrcpyptr
bra retrypathcomp
pathnotdir:
and.b #$e0,d0
cmp.b #$80,d0
beq pathcompkanji
cmp.b #$e0,d0
bne pathcomploop
pathcompkanji:
tst.b (a2)+
bne pathcomploop
exitpathcomp:
tst.w lastchange
bne skiplastchange
movem.l d1/a0/a2,-(sp) * last change
move.l a0,a2 * input path
move.l d1,a1 * buffer
bsr linkcheck2
movem.l (sp)+,d1/a0/a2
tst.w d0
bmi errreturn
move.w 256+2(a1),d0
tst.w d0
beq returnpathcomp
lea 8(a1),a3
move.l a0,a2
loopstrcpy:
move.b (a3)+,(a2)+
bne loopstrcpy
skiplastchange:
returnpathcomp:
move.l a0,a2
moveq.l #0,d0
errreturn:
rts
***
*** 単純ファイル名展開
***
linkcheck:
move.l (a6),a2
linkcheck3:
lea buffer(pc),a1
linkcheck2:
clr.w 256+2(a1) *change
retry:
move.l oldvectCHMOD(pc),$1800+$43*4.w
move.w #-1,-(sp)
move.l a2,-(sp)
linkswitch:
DOS _CHMOD
addq.w #6,sp
lea.l KeepEntCHMOD(pc),a0
move.l a0,$1800+$43*4.w
btst.l #6,d0
o_flagarea:
bne.s openlinkfile * short only
tst.b d0
bne normalopen
move.l oldvectOPEN(pc),$18f4.w
clr.w -(sp)
move.l a2,-(sp) * fname
DOS _OPEN
addq.w #6,sp
lea.l KeepEntOPEN(pc),a0
move.l a0,$18f4.w
tst.l d0
bmi normalopen
pea 257.w
move.l a1,-(sp) * buffer
move.w d0,-(sp)
DOS _READ
move.l d0,d1
DOS _CLOSE
lea 10(sp),sp
cmp.l #256,d1 * sizecheck
bne normalopen
cmp.l #'LINK',(a1)
bne normalopen
cmp.l #' :',4(a1)
bne normalopen
linkfileok:
lea 8(a1),a2
addq.w #1,256+2(a1) * change
move.w 256+2+2(a1),d0 * norec
cmp.w 256+2(a1),d0
bne retry
moveq.l #-2,d0
rts
normalopen:
moveq.l #0,d0
rts
*** o-format
openlinkfile:
move.l oldvectOPEN(pc),$18f4.w
clr.w -(sp)
move.l a2,-(sp) * fname
DOS _OPEN
addq.w #6,sp
lea.l KeepEntOPEN(pc),a0
move.l a0,$18f4.w
tst.l d0
bmi normalopen
pea 240.w
pea 8(a1)
move.w d0,-(sp)
DOS _READ
DOS _CLOSE
lea 10(sp),sp
lea 8(a1),a0
strchr0dloop:
move.b (a0)+,d0
beq linkfileok
cmp.b #$a,d0
beq strchr0dexit
cmp.b #$d,d0
bne strchr0dloop
strchr0dexit:
clr.b -(a0)
bra linkfileok
***
*** static バッファ
***
buffer:
.ds.b 256
filesbuf:
.ds.b 2
change:
.dc.w 0
norec:
.dc.w 32
lastchange:
.dc.w 0
pathbuf:
.ds.b 256
.even
KeepEnd:
***
*** 非常駐部
***
** Human v3
_Human3:
lea.l $1800+$50*4.w,a0
lea.l $30*4(a0),a1
moveq.l #47,d0
human3_vect_loop:
move.l (a0)+,(a1)+
dbra d0,human3_vect_loop
rts
**
_Start:
lea stackbuf,sp
pea titlemes(pc)
DOS _PRINT
moveq.l #0,d4
move.l d4,(sp)
DOS _SUPER
move.l d0,(sp)
tst.b (a2)+
beq keepcheck
* get arglist
getargloop:
skipspace:
skiptab:
move.b (a2)+,d0
beq keepcheck
cmp.b #' ',d0
beq skipspace
cmp.b #9,d0
beq skiptab
cmp.b #'-',d0
bne printusage
move.b (a2)+,d0
beq printusage
cmp.b #'o',d0
beq use_o_format
* bne not_o_flag
* move.w #'Nq',o_flagarea *?
* bra getargloop
not_o_flag:
cmp.b #'r',d0
bne printusage
moveq.l #1,d4
bra getargloop
keepcheck:
move.w #'Nq',o_flagarea *?
use_o_format:
* check
searchloop:
move.l (a0),a0
cmp.l #'SYMB',$100(a0)
bne nextsearch
cmp.l #'LINK',$104(a0)
beq findit
nextsearch:
tst.l (a0)
bne searchloop
notfound:
tst.w d4 * is keepon?
bne printnotkeep
* keep memory
lea dosvectortable(pc),a0
lea chgvectable(pc),a1
moveq.l #CHGVECTN-1,d2
keeponloop:
move.l (a1)+,-(sp)
move.w (a1)+,-(sp)
DOS _INTVCS
addq.w #6,sp
move.l d0,(a0)+
dbra d2,keeponloop
jsr _Human3
pea keeponmes(pc)
DOS _PRINT
addq.w #4,sp
DOS _SUPER
addq.w #4,sp
clr.w -(sp)
move.l #KeepEnd-KeepStart,-(sp)
DOS _KEEPPR
findit:
tst.w d4 * is keepon?
beq printalready
cmp.l #VERSION,$10c(a0)
bcs printversionerr
* cancel memory
move.l $100+16(a0),a1
lea chgvectable+4(pc),a2
moveq.l #CHGVECTN-1,d2
keepoffloop:
move.l (a1)+,-(sp)
move.w (a2)+,-(sp)
DOS _INTVCS
addq.w #6,sp
addq.w #4,a2
dbra d2,keepoffloop
pea 16(a0)
DOS _MFREE
pea keepoffmes(pc)
DOS _PRINT
addq.w #8,sp
jsr _Human3
DOS _SUPER
addq.w #2,sp
clr.w (sp)
DOS _EXIT2
printusage:
pea usagemes(pc)
errexit:
DOS _PRINT
addq.w #4,sp
DOS _SUPER
addq.w #2,sp
move.w #1,(sp)
DOS _EXIT2
printnotkeep:
pea notkeepmes(pc)
bra errexit
printalready:
pea alreadymes(pc)
bra errexit
printversionerr:
pea versionmes(pc)
bra errexit
chgvectable:
.dc.l KeepEntMKDIR
.dc.w _MKDIR
.dc.l KeepEntRMDIR
.dc.w _RMDIR
.dc.l KeepEntCHDIR
.dc.w _CHDIR
.dc.l KeepEntCREATE
.dc.w _CREATE
.dc.l KeepEntOPEN
.dc.w _OPEN
.dc.l KeepEntDELETE
.dc.w _DELETE
.dc.l KeepEntCHMOD
.dc.w _CHMOD
.dc.l KeepEntFILES
.dc.w _FILES
.dc.l KeepEntRENAME
.dc.w _RENAME
.dc.l KeepEntMAKETMP
.dc.w _MAKETMP
.dc.l KeepEntNEWFILE
.dc.w _NEWFILE
.dc.l KeepEntASSIGN
.dc.w _ASSIGN
titlemes:
.dc.b 'link.x Version ' * even
.dc.l VERSION
.dc.b ' 1991/95 H.Ogasawara (COR.)',13,10,0
usagemes:
.dc.b 'usage: link [-r]',13,10,0
notkeepmes:
.dc.b '常駐していません',13,10,0
alreadymes:
.dc.b '既に常駐しています',13,10,0
keepoffmes:
.dc.b '開放しました',13,10,0
keeponmes:
.dc.b '常駐しました',13,10,0
versionmes:
.dc.b 'バージョンが違います',13,10,0
.even
.bss
.ds.b 4096
stackbuf:
.end _Start